﻿define(['ko'], function(ko) {
	var Product = function() {
		var self = this;
		self.code = ko.observable();
		self.name = ko.observable();
		self.shortName = ko.observable();
		self.image = ko.observable();
		self.retailPrice = ko.observable();
		self.fobPrice = ko.observable();
		self.specialPrice = ko.observable();
		self.membershipPrice = ko.observable();
		self.gridThumbImage = ko.observable();
		self.listThumbImage = ko.observable();
		self.shortDescription = ko.observable();
		self.description = ko.observable();
		self.listImage = ko.observableArray();
		self.listCabinetPartImage = ko.observableArray();
		self.isChecked = ko.observable(false);
		self.isChecked = ko.observable(false);
		self.showFloat = ko.observable(false);
		self.discoutAmount = ko.computed(function() {
			var discount = parseFloat(self.retailPrice()) - parseFloat(self.specialPrice());
			return Math.round(discount);
		});
		self.discoutPercent = ko.computed(function() {
			if (self.retailPrice() == 0) return 0;
				var percent =  (-parseFloat(self.specialPrice()) + parseFloat(self.retailPrice()))/ parseFloat(self.retailPrice());
				return Math.round(percent * 100) + "%";
		});
		return self;
	};
	return Product;
});
